<%--
  Created by IntelliJ IDEA.
  User: 14258
  Date: 2020/9/8
  Time: 16:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>ajax</title>
    <script type="text/javascript" src="js/jquery-1.8.0.min.js" ></script>
    <script type="text/javascript">
      $(function () {
        $("#username").blur(function () {
          //1.接收参数
          var uname = $(this).val();
          //2.发送Ajax请求
          // $.ajax({
          //   url:"/test",
          //   data:"username="+uname,
          //   type:"post",
          //   dataType:"text",
          //   success:function (result) {
          //     $("#rs").html(result);
          //   },
          //   error:function () {
          //     $("#rs").html("出现未知错误")
          //   }
          // });
          $.post("/test","username="+uname,function (result) {
            $("#rs").html(result);
          });
        });
      })
    </script>
  </head>
  <body>
  请输入用户名：<input type="text" id="username" name=""><span id="rs"></span>
  </body>
</html>
